#include "main.h"
sbit DJ = P1 ^ 0;
unsigned char Counter = 0;
unsigned char Compare = 0;
void main()
{
    unsigned char Command = 0;
    unsigned char i = 0;
    Timer1Init();
    Int_Cut();
    Timer0_Init();
    Compare = 10;
    //LED_put(1, 0);
    
    while (1)
    {
        LED_put(1, i);
        if (Command_Flag() || Repeat_Flag())
        {
            Command = Re_Command();
            if (Command)
            {
                if (Command == KEY_0)
                {
                    i = 0;
                    Compare = 0;
                }
                if (Command == KEY_1)
                {
                    i = 1;
                    Compare = 25;
                }
                if (Command == KEY_2)
                {
                    i = 2;
                    Compare = 50;
                }
                if (Command == KEY_3)
                {
                    i = 3;
                    Compare = 100;
                }
            }
        }
    }
}

void Timer_Cut() interrupt 3
{
    TL1 = 0x91; // 设置定时初值
    TH1 = 0xFF; // 设置定时初值
    Counter++;
    Counter = Counter % 100;
    if (Counter < Compare)
    {
        DJ = 1;
    }
    else
    {
        DJ = 0;
    }
}